#include <iostream>
#include <vector>
using namespace std;
#define int long long
signed main()
{
    int n, m;
    cin >> n >> m;
    vector<int> nums(n);
    vector<int> sum(n+1,0);//代表i个数的和
    for (int i = 0; i < n; i++)
    {
        cin >> nums[i];
    }
    for(int i=1;i<=n;i++) sum[i]=sum[i-1]+nums[i-1];
    int l, r;
    while (m--)
    {
        cin >> l >> r;
        cout<<sum[r]-sum[l-1]<<endl;
    }
}
// 64 位输出请用 printf("%lld")